package com.ruoyi.business.service.impl;

import com.ruoyi.business.domain.WmsStoreRegion;
import com.ruoyi.business.mapper.WmsStoreRegionMapper;
import com.ruoyi.business.service.IWmsStoreRegionService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 库区管理Service业务层处理
 * 
 * @author yunlong
 * @date 2023-12-19
 */
@Service
public class WmsStoreRegionServiceImpl implements IWmsStoreRegionService
{
    @Autowired
    private WmsStoreRegionMapper wmsStoreRegionMapper;

    /**
     * 查询库区管理
     * 
     * @param id 库区管理ID
     * @return 库区管理
     */
    @Override
    public WmsStoreRegion selectWmsStoreRegionById(Long id)
    {
        return wmsStoreRegionMapper.selectWmsStoreRegionById(id);
    }

    @Override
    public WmsStoreRegion selectWmsStoreRegionBySn(String sn) {
        WmsStoreRegion wmsStoreRegion = new WmsStoreRegion();
        wmsStoreRegion.setRegionSn(sn);
        List<WmsStoreRegion> list = wmsStoreRegionMapper.selectWmsStoreRegionList(wmsStoreRegion);
        if(list.isEmpty()){
            return null;
        }else{
            return list.get(0);
        }
    }

    /**
     * 查询库区管理列表
     * 
     * @param wmsStoreRegion 库区管理
     * @return 库区管理
     */
    @Override
    public List<WmsStoreRegion> selectWmsStoreRegionList(WmsStoreRegion wmsStoreRegion)
    {
        return wmsStoreRegionMapper.selectWmsStoreRegionList(wmsStoreRegion);
    }

    /**
     * 新增库区管理
     * 
     * @param wmsStoreRegion 库区管理
     * @return 结果
     */
    @Override
    public int insertWmsStoreRegion(WmsStoreRegion wmsStoreRegion)
    {
        wmsStoreRegion.setCreateTime(DateUtils.getNowDate());
        return wmsStoreRegionMapper.insertWmsStoreRegion(wmsStoreRegion);
    }

    /**
     * 修改库区管理
     * 
     * @param wmsStoreRegion 库区管理
     * @return 结果
     */
    @Override
    public int updateWmsStoreRegion(WmsStoreRegion wmsStoreRegion)
    {
        wmsStoreRegion.setUpdateTime(DateUtils.getNowDate());
        return wmsStoreRegionMapper.updateWmsStoreRegion(wmsStoreRegion);
    }

    /**
     * 删除库区管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWmsStoreRegionByIds(String ids)
    {
        return wmsStoreRegionMapper.deleteWmsStoreRegionByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除库区管理信息
     * 
     * @param id 库区管理ID
     * @return 结果
     */
    @Override
    public int deleteWmsStoreRegionById(Long id)
    {
        return wmsStoreRegionMapper.deleteWmsStoreRegionById(id);
    }
}
